package com.my.app.tools.pojo;

import com.baidu.aip.util.Base64Util;
import com.google.common.collect.Lists;
import com.my.app.tools.core.service.common.AppConfigService;
import com.my.app.tools.core.service.common.ImageService;
import com.my.app.tools.util.LogUtil;

import java.awt.image.BufferedImage;
import java.util.List;

public class AppConstants {
    // 标题
    public static final List<String> MY_APP_TITLE_ITEMS = Lists.newArrayList("欢迎使用「我的工具」", "QQ：343802696", "微博：http://weibo.com/guochaohui");
    // 编码
    public static final String ENCODING_UTF8 = "UTF-8";
    // 编码
    public static final String ENCODING_GBK = "GBK";
    // 图片最大size
    public static final long IMAGE_MAX_SIZE = 1000 * 1000 * 1000;
    // app读取配置文件名称
    public static String MY_TOOLS_APP_CONFIG_XML_FILE_NAME = "MyToolsAppConfig.xml";

    private static BufferedImage APP_ICON;

    public static final BufferedImage getAppIcon() {
        if (APP_ICON != null) {
            return APP_ICON;
        }
        try {
            byte[] iconImageData = Base64Util.decode(AppConfigService.readStringConfig("/app-config/icon"));
            APP_ICON = ImageService.bytesToImage(iconImageData);
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error(e.getMessage());
        }
        return APP_ICON;
    }
}
